<?php


namespace app\mall\model\User;


use think\facade\Db;
use think\Model;

class PartnerModel extends Model
{

    /**
     * 数据表名
     * @var string
     */
    protected $name = "partner";

    /**
     * 根据条件查询单条数据
     * @param $where
     * @param string $field
     * @return mixed
     * @throws
     */
    public static function getPartnerWhere($where = [],$field="*")
    {
        if(!empty($where)){
            $partner = Db::name("partner")->field($field)->where($where)->find();
        }else{
            $partner = Db::name("partner")->field($field)->find();
        }
        return $partner;
    }

    /**
     * 添加返回ID
     * @param $data
     * @return int
     */
    public static function addPartner($data)
    {
        $id = Db::name('partner')->insertGetId($data);
        return $id;
    }

    /**
     * 更新
     * @param $where
     * @param $save
     * @return int
     * @throws
     */
    public static function updatePartnerWhere($where,$save)
    {
        $flag = Db::name('partner')->where($where)->update($save);
        return $flag;
    }


}